﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace KNXObjects.ValueObjects
{
    public class SwitchingValue : ValueObjectBase<bool>
    {
        #region Constructors

        public SwitchingValue(bool value)
        {
            Value = value;
        }

        public SwitchingValue(string value)
        {
            value = value.ToLower();
            if (value == "1" || value == "on" || value == "true")
                Value = true;
            else if (value == "0" || value == "off" || value == "false")
                Value = false;
            else
            {
                throw new ApplicationException("Invalid switching value");
            }
        }

        #endregion

        #region Override

        public override string ToString()
        {
            return Value ? "On" : "Off";
        }

        #endregion
    }
}
